package net.hn.hnms.biz.cockpit.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.hn.hnms.biz.cockpit.domain.WorkflowSystem;
import net.hn.hnms.biz.cockpit.mapper.WorkflowSystemMapper;
import net.hn.hnms.biz.cockpit.service.IWorkflowSystemService;
import net.hn.hnms.sys.common.core.utils.StringUtils;
import org.springframework.stereotype.Service;

@Service
public class WorkflowSystemServiceImpl extends ServiceImpl<WorkflowSystemMapper, WorkflowSystem> implements IWorkflowSystemService {

    @Override
    public WorkflowSystem getWorkflowInfo(String mineCode) {
        WorkflowSystem result = new WorkflowSystem();
        WorkflowSystem workflowSystem = baseMapper.selectOne(new LambdaQueryWrapper<WorkflowSystem>().eq(WorkflowSystem::getMineCode, mineCode).orderByDesc(WorkflowSystem::getCheckPeriod).last("limit 1"));
        if (workflowSystem != null) {
            BeanUtil.copyProperties(workflowSystem, result);
        }
        return result;
    }

}
